package skins {
	import flash.display.Graphics;
	
	import mx.skins.Border;
	import mx.styles.StyleManager;
	
	public class WhProgressIndeterminateSkin extends Border {
		
        //------------------------------------------------------------
        //
        // variables
        //
        //------------------------------------------------------------
		
		//----------------------------------
		//  measuredWidth
	    //----------------------------------

	    override public function get measuredWidth():Number {
	        return 195;
	    }
	    
	    //----------------------------------
		//  measuredHeight
	    //----------------------------------

	    override public function get measuredHeight():Number {
	        return 6;
	    }
		
        //------------------------------------------------------------
        //
        // overriden methods
        //
        //------------------------------------------------------------

		override protected function updateDisplayList(w:Number, h:Number):void {
			super.updateDisplayList(w, h);
	
			var barColorStyle:* = getStyle("barColor");
			var barColor:uint = StyleManager.isValidStyleValue(barColorStyle) ?
								barColorStyle :
								getStyle("themeColor");
				
			var barColor0:Number = 0xEEEEEE;
			var hatchInterval:Number = getStyle("indeterminateMoveInterval");
			
			// Prevents a crash when hatchInterval == 0. Really the indeterminateMoveInterval style should
			// not be hijacked to control the width of the segments on the bar but I'm not sure this is
			// unavoidable while retaining backwards compatibility (see Bug 12942)
			if (isNaN(hatchInterval) || hatchInterval == 0)
				hatchInterval = 28;
			
			var barWidth:Number = hatchInterval / 2;
			var hh:Number = h - 2;
			
			var g:Graphics = graphics;
			
			g.clear();
			
			// Hatches
			for (var x:int = 0; x < w + hh; x += hatchInterval) {
				g.beginFill(barColor0, 0.8);
				g.moveTo(x, 1);
				g.lineTo(x + barWidth, 1);
				g.lineTo(x + barWidth - hh, h - 1);
				g.lineTo(x + barWidth - hh - barWidth, h - 1);
				g.lineTo(x, 1);
				g.endFill();
			}
		}
		
        //------------------------------------------------------------
        //
        // constructor
        //
        //------------------------------------------------------------

		public function WhProgressIndeterminateSkin() {
			super();
		}

	}
}